package com.picture.controller;

import com.picture.pojo.dto.UserLogin;
import com.picture.pojo.dto.UserRegisterDTO;
import com.picture.result.Result;
import com.picture.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("picture/user")
@CrossOrigin
@Api(tags = "用户类相关接口")
@Slf4j
public class UserController {


    @Autowired
    private UserService userService;

    @ApiOperation("登录")
    @PostMapping("login")
    public Result login(@RequestBody UserLogin userLoginVO){
        Result result = userService.login(userLoginVO);

        return result;
    }
    @GetMapping("getUserInfo")
    public Result userInfo(@RequestHeader String token){
        Result result = userService.getUserInfo(token);
        return result;
    }
    @PostMapping("checkUserName")
    public Result checkUserName(String username){
        Result result = userService.checkUserName(username);
        return result;
    }
    @ApiOperation("注册")
    @PostMapping("regist")
    public Result regist(@RequestBody UserRegisterDTO userRegisterDTO){

        Result result = userService.regist(userRegisterDTO);
        return result;
    }


}
